<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\Agent\Level;
use App\Http\Controllers\Api\Fee;
use App\Http\Controllers\Api\Good;
use App\Http\Controllers\Api\Index;
use App\Http\Middleware\MemAuth;
use App\Http\Controllers\Api\Order;
use App\Http\Middleware\AgentAuth;
use App\Http\Controllers\AgentController;
use App\Http\Controllers\Agent\With;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/
Route::middleware(MemAuth::class)->group(function () {
    Route::post('/index', [Index::class, 'index']);
    Route::post('/fee', [Fee::class, 'index']);
    Route::post('/good', [Good::class, 'index']);
    Route::prefix('/order')->group(function(){
        Route::post('/',[Order::class,'index']);
        Route::post('/pay',[Order::class,'pay']);
    });
    Route::post('/reg',[AgentController::class,'reg']);
});

Route::middleware(AgentAuth::class)->prefix('agent')->group(function () {
    Route::post('/login',[AgentController::class,'login'])->withoutMiddleware(AgentAuth::class);
    Route::post('/logout',[AgentController::class,'logout']);
    Route::middleware(MemAuth::class)->post('/', [\App\Http\Controllers\Agent\Index::class, 'index']);
    Route::post('/order', [\App\Http\Controllers\Agent\Order::class, 'index']);
    Route::post('/log', [\App\Http\Controllers\Agent\Index::class, 'log']);
    Route::post('/recharge', [\App\Http\Controllers\Agent\Index::class, 'recharge']);
    Route::post('/team', [\App\Http\Controllers\Agent\Index::class, 'team']);
    Route::prefix('/level')->middleware(MemAuth::class)->group(function(){
        Route::post('/',[Level::class,'index']);
        Route::post('/pay',[Level::class,'pay']);
    });
    Route::prefix('/with')->group(function(){
        Route::post('/',[With::class,'index']);
        Route::post('/save',[With::class,'save']);
        Route::post('/log',[With::class,'log']);
    });
});